<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');
?>
<div class="pad-10">
	<form method="post" action="?m=guestbook&c=guestbook_admin&a=edit&gid=<?php echo $_GET['gid']?>" name="myform" id="myform">
		<table class="table_form" width="100%">
			<tbody>
				<tr>
					<th width="80">留言人</th>
					<td><input name="guestbook[username]" id="username" value="<?php echo $an_info['username']?>" class="input-text" type="text" size="30" ></td>
				</tr>
				<tr>
					<th>留言时间</th>
					<td><?php echo form::date('guestbook[addtime]', date('Y-m-d H:i:s', $an_info['addtime']), 1)?></td>
				</tr>
				<tr>
					<th><?php echo L('guestbook_title')?></th>
					<td><input name="guestbook[title]" id="title" value="<?php echo new_html_special_chars($an_info['title'])?>" class="input-text" type="text" size="50" ></td>
				</tr>
				<tr>
					<th><?php echo L('guestbook_content')?></th>
					<td >
					<textarea name="guestbook[content]" id="content"><?php echo $an_info['content']?></textarea>
					<?php echo form::editor('content','basic');?>
					</td>
				</tr>
				<tr>
			  	<th>联系电话</th>
			  	<td><input name="guestbook[phone]" id="phone" value="<?php echo $an_info['phone']?>" class="input-text" type="text" size="30" ></td>
				</tr>
				<tr>
					<th>邮件</th>
					<td><input name="guestbook[email]" id="email" value="<?php echo $an_info['email']?>" class="input-text" type="text" size="30" ></td>
				</tr>
				<tr>
					<th>联系地址</th>
					<td><input name="guestbook[address]" id="address" value="<?php echo $an_info['address']?>" class="input-text" type="text" size="50" ></td>
				</tr>
				<?php if ($an_info['status']==1){?>
					<tr>
						<th></th>
						<td></td>
					</tr>
				<tr>
					<th>回复人</th>
					<td><input name="guestbook[replyname]" id="replyname" value="<?php echo $an_info['replyname']?>" class="input-text" type="text" size="50" ></td>
				</tr>
				<tr>
					<th>回复时间</th>
					<td><?php echo form::date('guestbook[replytime]', date('Y-m-d H:i:s', $an_info['replytime']), 1)?></td>
				</tr>
				<tr>
					<th>回复内容</th>
					<td>
						<textarea name="guestbook[replycontent]" id="replycontent"><?php echo $an_info['replycontent']?></textarea>
						<?php echo form::editor('replycontent','basic');?>
					</td>
				</tr>
				<?php }?>
			</tbody>
		</table>
		<input type="submit" name="dosubmit" id="dosubmit" value=" <?php echo L('ok')?> " class="dialog">&nbsp;<input type="reset" class="dialog" value=" <?php echo L('clear')?> ">
	</form>
</div>
</body>
</html>
<script type="text/javascript">
// function load_file_list(id) {
// 	$.getJSON('?m=admin&c=category&a=public_tpl_file_list&style='+id+'&module=guestbook&templates=show&name=announce&pc_hash='+pc_hash, function(data){$('#show_template').html(data.show_template);});
// }

$(document).ready(function(){

	$.formValidator.initConfig({
		formid:"myform",
		autotip:true,
		onerror:function(msg,obj){
			window.top.art.dialog({ content:msg, lock:true, width:'220', height:'70' }, function(){ this.close(); $(obj).focus(); })
		}
	});

	$('#title').formValidator({
		onshow:"<?php echo L('input_announce_title')?>",
		onfocus:"标题不能为空",
		oncorrect:"<?php echo L('right')?>"
	})
	.inputValidator({
		min:1,
		onerror:"<?php echo L('title_cannot_empty')?>"
	})
	.defaultPassed();

	$("#content").formValidator({
		autotip:true,onshow:"",onfocus:"<?php echo L('announcements_cannot_be_empty')?>"
	})
	.functionValidator({
		fun:function(val,elem){
		  //获取编辑器中的内容
			var oEditor = CKEDITOR.instances.content;
			var data = oEditor.getData();
			(data=='') ? '<?php echo L('announcements_cannot_be_empty')?>' : true;
		}
	})
	.defaultPassed();

});
</script>
